import request from '@/utils/request'
export function listSaleByPage(query) {
  return request({
    url: '/sale/page',
    method: 'get',
    params: query
  })
}
// 获取订单列表
export function getAllSaleList(data) {
  return request({
    url: '/sale/listAllSale',
    method: 'post',
    data
  })
}
// 开始新的销售
export function makeNewSale() {
  return request({
    url: '/sale/makeNewSale',
    method: 'get'
  })
}
// 录入订单明细
export function enterItem(data) {
  return request({
    url: '/sale/enterItem',
    method: 'post',
    data
  })
}
// 结束录入
export function endSale() {
  return request({
    url: '/sale/endSale',
    method: 'get'
  })
}

// 确认支付
export function makePayment(sale, cashTendered) {
  const url = `/sale/makePaymentByCash?cashTendered=${cashTendered}`
  return request({
    url,
    method: 'post',
    data: sale
  })
}


// 删除一行订单明细
export function deleteSaleItem(data) {
  return request({
    url: '/saleClothes/deleteSaleClothes',
    method: 'post',
    data
  })
}
// 取消订单
export function cancelSale(data) {
  return request({
    url: '/sale/cancelSale',
    method: 'post',
    data
  })
}
// 获取颜色列表
export function getColorList(data) {
  return request({
    url: '/color/listAllColor',
    method: 'post',
    data
  })
}
// 获取尺码列表
export function getSizeList(data) {
  return request({
    url: '/size/listAllSize',
    method: 'post',
    data
  })
}
// 通过颜色尺码获取规格
export function listNormByColorAndSize(data) {
  return request({
    url: '/norm/listNormByColorAndSize',
    method: 'post',
    data
  })
}
// 获取折扣价
export function getDiscountPrice(price) {
  const url = `/sale/getClothesNormDiscountPrice?price=${price}`
  return request({
    url,
    method: 'get'
  })
}
// alipay
export function makePaymentByAli(data) {
  return request({
    url: '/sale/alipay',
    method: 'post',
    data
  })
}
// alipay
export function notify(data) {
  return request({
    url: '/sale/notify',
    method: 'get',
    params: data
  })
}
// 退货
export function returnBack(data) {
  return request({
    url: '/sale/returnBack',
    method: 'post',
    data
  })
}
// 换货
export function exchange(data) {
  return request({
    url: '/sale/exchange',
    method: 'post',
    data
  })
}

// 年度销售额
export function yearPie(year) {
  const url = `/saleClothes/yearPie?year=${year}`
  return request({
    url,
    method: 'get'
  })
}


// 时间段各类销售额
export function timePie(startDate, endDate) {
  const url = `/saleClothes/timePie?startDate=${startDate}&endDate=${endDate}`
  return request({
    url,
    method: 'get'
  })
}